#include <bits/stdc++.h>
using namespace std;
const int _ = 1.5e5 + 10;
const int __ = 6e5 + 10;
int n, m, a, b, e, hd[_], nx[__], to[__];
bool flag;
inline void add(int u, int v) {
    e++;
    nx[e] = hd[u];
    to[e] = v;
    hd[u] = e;
}
int len[1010][1010];
long long dis[_];
bool vis[1010];
void dfs(int x, int f) {
    for (int i = hd[x]; i; i = nx[i]) {
        int y = to[i];
        if (y != f) {
            dis[y] = dis[x] + 1;
            dfs(y, x);
        }
    }
}
int main() {
    freopen("edge.in", "r", stdin);
    freopen("edge.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> a >> b;
    if (m == n - 1) flag = true;
    while (m--) {
        int u, v;
        cin >> u >> v;
        add(u, v);
        add(v, u);
    }
    if (flag) {
        dis[1] = 0;
        dfs(1, 0);
        for (int i = 2; i <= n; i++) {
            long long tmp1 = (long long) dis[i] * a;
            long long tmp2 = (long long) (dis[i] >> 1) * b + (long long) (dis[i] & 1) * a;
            cout << min(tmp1, tmp2);
            if (i != n) cout << '\n';
        }
        cout << endl;
    } else {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                len[i][j] = -1;
            }
        }
        for (int u = 1; u <= n; u++) {
            for (int i = hd[u]; i; i = nx[i]) {
                int v = to[i];
                len[u][v] = a;
            }
        }
        for (int u = 1; u <= n; u++) {
            for (int i = hd[u]; i; i = nx[i]) {
                int v = to[i];
                for (int j = hd[u]; j; j = nx[j]) {
                    int w = to[j];
                    if (v != w) {
                        if (len[v][w] == -1) {
                            len[v][w] = b;
                        }
                    }
                }
            }
        }
        for (int i = 1; i <= n; i++) {
            dis[i] = -1LL;
        }
        dis[1] = 0;
        while (true) {
            int pos = -1;
            for (int i = 1; i <= n; i++) {
                if (!vis[i] && dis[i] != -1) {
                    if (pos == -1 || dis[i] < dis[pos]) {
                        pos = i;
                    }
                }
            }
            if (pos == -1) break;
            vis[pos] = true;
            for (int i = 1; i <= n; i++) {
                if (!vis[i] && len[pos][i] != -1) {
                    long long tmp = dis[pos] + len[pos][i];
                    if (dis[i] == -1 || dis[i] > tmp) {
                        dis[i] = tmp;
                    }
                }
            }
        }
        for (int i = 2; i <= n; i++) {
            cout << dis[i];
            if (i != n) cout << '\n';
        }
        cout << endl;
    }
    return 0;
}